<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    body {margin: 0;overflow: hidden;}
    #canvas {background-color: antiquewhite;}
  </style>
</head>
<body>
  <canvas id="canvas"></canvas>
  <script>
    /** @type {HTMLCanvasElement} */
    const canvas = document.querySelector('#canvas');
    canvas.width = window.innerWidth;
    canvas.height = window.innerHeight;
    const ctx = canvas.getContext('2d');
    const text = '火神山';
    const colors = ['yellow', 'gold']

    const [x,y] = [50,300];

    ctx.font = 'bold 220px arial';

    function draw () {
      ctx.save();
      ctx.strokeStyle = colors[0];
      ctx.lineWidth = 3;
      ctx.setLineDash([8]);
      ctx.strokeText(text,x,y);
      // 第二部分虚线
      ctx.lineDashOffset = 8;
      ctx.strokeStyle = colors[1];
      // 光晕
      ctx.shadowColor = 'orange';
      // 多画几遍光晕
      for (let i = 25; i > 3; i -= 2) {
        ctx.shadowBlur = 1;
        ctx.strokeText(text,x,y);
      }
      ctx.restore();
    }
  
    draw();

    setInterval(() => {
      ctx.clearRect(0,0,canvas.width,canvas.height);
      draw();
      colors.reverse();
    })

  </script>
</body>
</html>